﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@using FastCodeGeneration.Entity
@model FastCodeGeneration.Entity.Project
@{
    Layout = null;
}

<!doctype html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <link rel="icon" href="../dist/img/favicon-32x32.png" sizes="32x32" type="image/png">
    <link rel="icon" href="../dist/img/favicon-16x16.png" sizes="16x16" type="image/png">
    <meta name="keywords" content="响应式后台模板,开源免费后台模板,Bootstrap5后台管理系统模板">
    <meta name="description" content="bootstrap-admin基于bootstrap5的免费开源的响应式后台管理模板">
    <meta name="author" content="ajiho">
    <link href="~/lib/bootstrap-icons/font/bootstrap-icons.min.css" rel="stylesheet" />
    <link href="~/lib/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/css/bootstrap-admin.css" rel="stylesheet" />
    <title>bootstrap-admin开源免费响应式后台管理系统模板</title>
</head>
<body class="bg-body-tertiary py-3">
    <div class="container-fluid">
        <div class="card border-0 shadow-sm">
            <div class="card-body">
                <form id="form">
                    <input id="id" name="id" value="@Model.Id" hidden />
                    <div class="mb-3">
                        <label for="name" class="form-label">项目名</label>
                        <input type="text" class="form-control" id="name" name="name" value="@Model.Name">
                    </div>
                    <div class="mb-3">
                        <label for="company" class="form-label">机构</label>
                        <input type="text" class="form-control" id="company" name="company" value="@Model.Company">
                    </div>
                    <div class="mb-3">
                        <label for="dataBaseName" class="form-label">数据库</label>
                        <input type="text" class="form-control" id="dataBaseName" name="dataBaseName" value="@Model.DataBaseName">
                    </div>

                    <div class="mb-3">
                        <label for="dataBaseType" class="form-label">数据库类型</label>
                        <input type="text" class="form-control" id="dataBaseType" name="dataBaseType" value="@Model.DataBaseType">
                    </div>
                    <div class="mb-3">
                        <label for="ip" class="form-label">数据库服务器IP</label>
                        <input type="text" class="form-control" id="ip" name="ip" value="@Model.Ip">
                    </div>
                    <div class="mb-3">
                        <label for="port" class="form-label">数据库服务器端口</label>
                        <input type="text" class="form-control" id="port" name="Port" value="@Model.Port">
                    </div>
                    <div class="mb-3">
                        <label for="userName" class="form-label">用户名</label>
                        <input type="text" class="form-control" id="userName" name="userName" value="@Model.UserName">
                    </div>
                    <div class="mb-3">
                        <label for="password" class="form-label">密码</label>
                        <input type="text" class="form-control" id="password" name="password" value="@Model.Password">
                    </div>
                    <div class="mb-3">
                        <label for="serverTemplate" class="form-label">后端模板类型</label>
                        <input type="text" class="form-control" id="serverTemplate" name="serverTemplate" value="@Model.ServerTemplate">
                    </div>

                    <div class="mb-3">
                        <label for="viewTemplate" class="form-label">前端模板类型</label>
                        <input type="text" class="form-control" id="viewTemplate" name="viewTemplate" value="@Model.ViewTemplate">
                    </div>
                    <div class="mb-3">
                        <label for="projectPath" class="form-label">项目路径</label>
                        <input type="text" class="form-control" id="projectPath" name="projectPath" value="@Model.ProjectPath">
                    </div>
                    <div class="mb-3">
                        <label for="author" class="form-label">作者</label>
                        <input type="text" class="form-control" id="author" name="author" value="@(string.IsNullOrEmpty(Model.Author) ? "system":Model.Author)">
                    </div>

                    <div class="mb-3">
                        <label for="dateFormat" class="form-label">日期格式</label>
                        <input type="text" class="form-control" id="dateFormat" name="dateFormat" value="@(string.IsNullOrEmpty(Model.DateFormat) ? "yyyy-MM-dd":Model.DateFormat)">
                    </div>

                    @if (Model.Id == null)
                    {
                        <button type="submit" class="btn btn-primary">添加</button>
                    }
                    else
                    {
                        <button type="submit" class="btn btn-primary">修改</button>
                    }

                </form>
            </div>
        </div>


    </div>
    <!--回到顶部开始-->
    <a href="javaScript:" class="bsa-back-to-top"><i class='bi bi-arrow-up-short'></i></a>
    <!--回到顶部结束-->


    <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="~/lib/formvalidation/js/formvalidation.js"></script>
    <script src="~/lib/formvalidation/js/framework/bootstrap.js"></script>
    <script src="~/lib/formvalidation/js/language/zh_CN.js"></script>
    <script src="~/lib/mark/marked.js"></script>
    <script src="~/js/bootstrap-admin.js"></script>
    <script src="~/js/app.js"></script>
    <script>

        $("#form").formValidation({
            //验证字段
            fields: {
                name: { validators: { notEmpty: true } },
                company: { validators: { notEmpty: true } },
                dataBaseName: { validators: { notEmpty: true } },
                dataBaseType: { validators: { notEmpty: true } },
                ip: { validators: { notEmpty: true } },
                port: { validators: { notEmpty: true } },
                userName: { validators: { notEmpty: true } },
                password: { validators: { notEmpty: true } },
                serverTemplate: { validators: { notEmpty: true } },
                viewTemplate: { validators: { notEmpty: true } },
                author: { validators: { notEmpty: true } },
            }
        }).on('success.form.fv', function (e) {
            //阻止表单提交
            e.preventDefault();
            //得到表单对象
            let $form = $(e.target);
            let data = $form.serialize();

            //得到序列化数据
            $.ajax({
                url: "/Project/Save",
                method: 'post',
                data: data,
                success: function (res) {
                    console.log(res);
                    //添加成功
                    $.toasts({
                        type: 'success',
                        content: '修改成功',
                        delay: 1000,
                        autohide: true,
                        onHidden: function () {
                            parent.modalInstance.setData(true);
                            parent.modalInstance.close();
                        }
                    })

                }
            })

        });


    </script>

</body>
</html>
